<?php
/**
 * 
 * model() 帮助我们创建模型队形 
 * tableName() 帮助我们返回当前数据表的名字 是静态方法
 * @author Administrator
 *
 */
class categorylist extends CActiveRecord {
	// classname就是当前class 名字 chapters
	// 反悔当前模型对象的静态方法 固定的
	public static function model($className = __CLASS__) {
		return parent::model ( $className );
	}
	
	/**
	 * 返回当前数据表的名字
	 */
	public function tableName() {
		// 如果有前缀可以加两个括号 这样会自动关联
		// return '{{chapters}}';
		return 'categorylist';
	}
	
	
	/**
	 * 获取菜单分类
	 * @param unknown_type $lid
	 * @return unknown
	 */
	function getSubCategoryList($lid){
		//把获得的具体详细商品信息存入缓存，下次再来获得信息就去缓存读取
		$categoryListModel = categorylist::model();
		$sqlExt = "`title`";
		if ($lid == 0) { // origin
				$sqlExt = "`id` cid,`imgUrl`,`title` `title`";
			} else if ($lid == 1) { // Português
				$sqlExt = "`id` cid,`imgUrl`,`titlePor` `title`";
			} else if ($lid == 2) { // ????
				$sqlExt = "`id` cid,`imgUrl`,`titleArabic` `title`";
			} else if ($lid == 3) { // Italiano
				$sqlExt = "`id` cid,`imgUrl`,`titleItalian` `title`";
			} else if ($lid == 4) { // English
				$sqlExt = "`id` cid,`imgUrl`,`titleEn` `title`";
			} else if ($lid == 5) { // Fran?ais
				$sqlExt = "`id` cid,`imgUrl`,`titleFrench` `title`";
			} else if ($lid == 6) { // Deutsch
				$sqlExt = "`id` cid,`imgUrl`,`titleGermany` `title`";
			} else if ($lid == 7) { // 中文繁體
				$sqlExt = "`id` cid,`imgUrl`,`titleChineseSim` `title`";
			} else if ($lid == 8) { // 中文简体
				$sqlExt = "`id` cid,`imgUrl`,`titleChineseSim` `title`";
			} else if ($lid == 9) { // 韩语
				$sqlExt = "`id` cid,`imgUrl`,`titleKorean` `title`";
			} else if ($lid == 10) { // 西班牙语
				$sqlExt = "`id` cid,`imgUrl`,`titleSpanish` `title`";
			} else if ($lid == 11) { // 日语
				$sqlExt = "`id` cid,`imgUrl`,`titleJpn` `title`";
			}
		
		
		$categoryList = $categoryListModel->findAll(array (
				'select' => $sqlExt,
				'condition' => "hasBoard = 0"
		));
		return $categoryList;
	}
	
	

	/**
	 * 获取菜单分类
	 * @param unknown_type $lid
	 * @return unknown
	 */
	function getCategoryList($lid){
		//把获得的具体详细商品信息存入缓存，下次再来获得信息就去缓存读取
		$categoryListModel = categorylist::model();
		$sqlExt = "`title`";
		if ($lid == 0) { // origin
			$sqlExt = "`id` cid,`imgUrl`,`title` `title`";
		} else if ($lid == 1) { // Português
			$sqlExt = "`id` cid,`imgUrl`,`titlePor` `title`";
		} else if ($lid == 2) { // ????
			$sqlExt = "`id` cid,`imgUrl`,`titleArabic` `title`";
		} else if ($lid == 3) { // Italiano
			$sqlExt = "`id` cid,`imgUrl`,`titleItalian` `title`";
		} else if ($lid == 4) { // English
			$sqlExt = "`id` cid,`imgUrl`,`titleEn` `title`";
		} else if ($lid == 5) { // Fran?ais
			$sqlExt = "`id` cid,`imgUrl`,`titleFrench` `title`";
		} else if ($lid == 6) { // Deutsch
			$sqlExt = "`id` cid,`imgUrl`,`titleGermany` `title`";
		} else if ($lid == 7) { // 中文繁體
			$sqlExt = "`id` cid,`imgUrl`,`titleChineseSim` `title`";
		} else if ($lid == 8) { // 中文简体
			$sqlExt = "`id` cid,`imgUrl`,`titleChineseSim` `title`";
		} else if ($lid == 9) { // 韩语
			$sqlExt = "`id` cid,`imgUrl`,`titleKorean` `title`";
		} else if ($lid == 10) { // 西班牙语
			$sqlExt = "`id` cid,`imgUrl`,`titleSpanish` `title`";
		} else if ($lid == 11) { // 日语
			$sqlExt = "`id` cid,`imgUrl`,`titleJpn` `title`";
		}
	
	
		$categoryList = $categoryListModel->findAll(array (
				'select' => $sqlExt,
				'condition' => "hasBoard = 0"
		));
		return $categoryList;
	}
}